package cn.edu.kzjsxy.graduationproject.service.impl;

import cn.edu.kzjsxy.graduationproject.common.Page;
import cn.edu.kzjsxy.graduationproject.common.Result;
import cn.edu.kzjsxy.graduationproject.entity.DailyDormitoryCleanliness;
import cn.edu.kzjsxy.graduationproject.entity.DailyUnitCleanliness;
import cn.edu.kzjsxy.graduationproject.mapper.DailyUnitCleanlinessMapper;
import cn.edu.kzjsxy.graduationproject.service.IDailyUnitCleanlinessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 每日单元卫生检查记录表 服务实现类
 * </p>
 *
 * @author chén jiā jùn
 * @since 2024-04-14
 */
@Service
public class DailyUnitCleanlinessServiceImpl extends ServiceImpl<DailyUnitCleanlinessMapper, DailyUnitCleanliness> implements IDailyUnitCleanlinessService {

	@Autowired
	private DailyUnitCleanlinessMapper dailyUnitCleanlinessMapper;

//	根据条件查询卫生检查记录列表
	@Override
	public List<DailyUnitCleanliness> selectCleanlinessRecordsByCondition(DailyUnitCleanliness dailyUnitCleanliness) {
		List<DailyUnitCleanliness> dailyUnitCleanlinessList = dailyUnitCleanlinessMapper.selectCleanlinessRecordsByCondition(dailyUnitCleanliness);
		return dailyUnitCleanlinessList;
	}


//分页获取卫生检查记录
	@Override
	public Result<PageInfo<DailyUnitCleanliness> > selectCleanlinessRecordsByPage(Page page, DailyUnitCleanliness dailyUnitCleanliness) {
		// 设置分页
		PageHelper.startPage(page.getPageNum(), page.getPageSize());
		// 执行查询
		List<DailyUnitCleanliness> dailyUnitCleanlinessList = dailyUnitCleanlinessMapper.selectCleanlinessRecordsByCondition(dailyUnitCleanliness);
		PageInfo<DailyUnitCleanliness> pageInfo = new PageInfo<>(dailyUnitCleanlinessList);
		return Result.success(pageInfo);
	}
}
